package com.swas.util;

import org.springframework.util.DigestUtils;

/**
 * @author lxysky
 */
public class MD5Util {

    public static String generateMD5(String password) {
        return DigestUtils.md5DigestAsHex((password).getBytes());
    }

    public static String generateMD5(String password, Integer count) {
        for (int i = 0; i < count; i++) {
            password = DigestUtils.md5DigestAsHex((password).getBytes());
        }
        return password;
    }

    public static String generateMD5(String password, Integer count, String salt) {
        for (int i = 0; i < count; i++) {
            password = DigestUtils.md5DigestAsHex((password + salt).getBytes());
        }
        return password;
    }

}
